
package combat.dudes.server.protocol.implementation;

import gnu.cajo.invoke.Remote;

import java.rmi.RemoteException;
import java.util.Date;

import combat.dudes.protocol.data.DoublePoint;
import combat.dudes.protocol.data.PhysicalObject;
import combat.dudes.protocol.interfaces.TrackInt;
import combat.dudes.protocol.interfaces.UserInt;
import combat.dudes.protocol.types.PhysicalObjectType;
import combat.dudes.protocol.types.StandingType;
import combat.dudes.server.ServerApp;


/**
 * @author Laurens Andriessen
 * @version 1.0
 */
public class Track extends PhysicalObject implements TrackInt {

	private static final long serialVersionUID = 1L;

	// [ Inherited from PhysicalObject ]
	// String name
	// DoublePoint position
	// int altitude
	// double direction
	// double speed
	int trackID = 0;
	UserInt user = null;
	StandingType standing = StandingType.UNKNOWN;
	Date timestamp = null;

	public Track() {}

	public Track(String name, DoublePoint position, int altitude, double direction, double speed, int trackID, UserInt user, StandingType standing, Date timestamp) {
		super(PhysicalObjectType.TRACK, name, position, altitude, direction, speed);
		this.trackID = trackID;
		this.user = user;
		this.standing = standing;
		this.timestamp = timestamp;
	}

	@Override
	public int getTrackID() {
		return trackID;
	}
	@Override
	public void setTrackID(int trackID) {
		this.trackID = trackID;
	}

	@Override
	public UserInt getUser() {
		return user;
	}
	@Override
	public void setUser(UserInt user) {
		this.user = user;
	}

	@Override
	public StandingType getStanding() {
		return standing;
	}
	@Override
	public void setStanding(StandingType standing) {
		this.standing = standing;
	}

	@Override
	public Date getTimestamp() {
		return timestamp;
	}
	@Override
	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}

	@Override
	public Remote getUser_Remote() {
		try {
			return new Remote(getUser());
		} catch(RemoteException e) {
			ServerApp.onError("@Track.java, getUser_Remote()", e, false);
		}
		return null;
	}

}
